﻿using System.Drawing;
using System.Resources;
using System.Windows.Forms;

namespace AiFrame.Interface.WinUI.Windows.Controls
{
    public partial class FilterBar : UserControl
    {
        private const int FRAME_HEIGHT = 16;
        private FilterState _state;
        private ResourceManager _resourceManager;
        Image _curImage;

        private const string MSG_OFF = "Filter ausgeschaltet, es werden alle " +
                                       "Elemente angezeigt";

        private const string MSG_ON = "Filter eingeschaltet";

        public enum FilterState
        {
            On,
            Off
        } 
        
        public FilterBar()
        {
            InitializeComponent();
            Height = 16;
            _resourceManager = new ResourceManager("AiFrame.Interface.WinUI.Properties." +
            "Resources", this.GetType().Assembly);

            State = FilterState.Off;
        }

        public FilterState State
        {
            get
            {
                return _state;
            }
            set
            {
                _state = value;
                switch (value)
                {
                    case FilterState.On:
                        _curImage = (Image) _resourceManager.GetObject("filter_bar_on");
                        break;
                    case FilterState.Off:
                        _curImage = (Image) _resourceManager.GetObject("filter_bar_off");
                        break;
                }
                backPictureBox.Image = _curImage;
            }
        }

        private void backPictureBox_Paint(object sender, PaintEventArgs e)
        {
            /* Die Message vorbereiten */
            string msg = (State == FilterState.On) ? MSG_ON : MSG_OFF;
            
            /* Text zeichnen */
            Font font = new Font("Microsoft Sans Serif", 8, FontStyle.Regular);
            e.Graphics.DrawString(msg, font, new SolidBrush(Color.White),
                                  new PointF(5, 1));
        }
        
    }
}
